package com.kenai.jbosh;

import java.io.Closeable;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

final class ServiceLib
{
  private static final Logger LOG = Logger.getLogger(ServiceLib.class.getName());

  private static <T> T attemptLoad(Class<T> paramClass, String paramString)
  {
    if (LOG.isLoggable(Level.FINEST))
      LOG.finest("Attempting service load: " + paramString);
    try
    {
      Class localClass = Class.forName(paramString);
      if (!paramClass.isAssignableFrom(localClass))
      {
        if (LOG.isLoggable(Level.WARNING))
        {
          LOG.warning(localClass.getName() + " is not assignable to " + paramClass.getName());
          return null;
        }
      }
      else
      {
        Object localObject2 = paramClass.cast(localClass.newInstance());
        return localObject2;
      }
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      localLevel = Level.FINEST;
      localObject1 = localClassNotFoundException;
      LOG.log(localLevel, "Could not load " + paramClass.getSimpleName() + " instance: " + paramString, (Throwable)localObject1);
      return null;
    }
    catch (InstantiationException localInstantiationException)
    {
      while (true)
      {
        localLevel = Level.WARNING;
        localObject1 = localInstantiationException;
      }
    }
    catch (IllegalAccessException localIllegalAccessException)
    {
      while (true)
      {
        Level localLevel = Level.WARNING;
        Object localObject1 = localIllegalAccessException;
      }
    }
    return null;
  }

  private static void finalClose(Closeable paramCloseable)
  {
    if (paramCloseable != null);
    try
    {
      paramCloseable.close();
      return;
    }
    catch (IOException localIOException)
    {
      LOG.log(Level.FINEST, "Could not close: " + paramCloseable, localIOException);
    }
  }

  static <T> T loadService(Class<T> paramClass)
  {
    Iterator localIterator = loadServicesImplementations(paramClass).iterator();
    Object localObject;
    do
    {
      if (!localIterator.hasNext())
        throw new IllegalStateException("Could not load " + paramClass.getName() + " implementation");
      localObject = attemptLoad(paramClass, (String)localIterator.next());
    }
    while (localObject == null);
    if (LOG.isLoggable(Level.FINEST))
      LOG.finest("Selected " + paramClass.getSimpleName() + " implementation: " + localObject.getClass().getName());
    return localObject;
  }

  // ERROR //
  private static List<String> loadServicesImplementations(Class paramClass)
  {
    // Byte code:
    //   0: new 153	java/util/ArrayList
    //   3: dup
    //   4: invokespecial 154	java/util/ArrayList:<init>	()V
    //   7: astore_1
    //   8: aload_0
    //   9: invokevirtual 14	java/lang/Class:getName	()Ljava/lang/String;
    //   12: invokestatic 160	java/lang/System:getProperty	(Ljava/lang/String;)Ljava/lang/String;
    //   15: astore_2
    //   16: aload_2
    //   17: ifnull +11 -> 28
    //   20: aload_1
    //   21: aload_2
    //   22: invokeinterface 164 2 0
    //   27: pop
    //   28: ldc 2
    //   30: invokevirtual 168	java/lang/Class:getClassLoader	()Ljava/lang/ClassLoader;
    //   33: new 45	java/lang/StringBuilder
    //   36: dup
    //   37: ldc 170
    //   39: invokespecial 50	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   42: aload_0
    //   43: invokevirtual 14	java/lang/Class:getName	()Ljava/lang/String;
    //   46: invokevirtual 54	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   49: invokevirtual 57	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   52: invokevirtual 176	java/lang/ClassLoader:getResource	(Ljava/lang/String;)Ljava/net/URL;
    //   55: astore_3
    //   56: aconst_null
    //   57: astore 4
    //   59: aconst_null
    //   60: astore 5
    //   62: aconst_null
    //   63: astore 6
    //   65: aload_3
    //   66: invokevirtual 182	java/net/URL:openStream	()Ljava/io/InputStream;
    //   69: astore 4
    //   71: new 184	java/io/InputStreamReader
    //   74: dup
    //   75: aload 4
    //   77: invokespecial 187	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;)V
    //   80: astore 9
    //   82: new 189	java/io/BufferedReader
    //   85: dup
    //   86: aload 9
    //   88: invokespecial 192	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   91: astore 10
    //   93: aload 10
    //   95: invokevirtual 195	java/io/BufferedReader:readLine	()Ljava/lang/String;
    //   98: astore 11
    //   100: aload 11
    //   102: ifnonnull +20 -> 122
    //   105: aload 10
    //   107: invokestatic 197	com/kenai/jbosh/ServiceLib:finalClose	(Ljava/io/Closeable;)V
    //   110: aload 9
    //   112: invokestatic 197	com/kenai/jbosh/ServiceLib:finalClose	(Ljava/io/Closeable;)V
    //   115: aload 4
    //   117: invokestatic 197	com/kenai/jbosh/ServiceLib:finalClose	(Ljava/io/Closeable;)V
    //   120: aload_1
    //   121: areturn
    //   122: aload 11
    //   124: ldc 199
    //   126: invokevirtual 203	java/lang/String:matches	(Ljava/lang/String;)Z
    //   129: ifne -36 -> 93
    //   132: aload_1
    //   133: aload 11
    //   135: invokevirtual 206	java/lang/String:trim	()Ljava/lang/String;
    //   138: invokeinterface 164 2 0
    //   143: pop
    //   144: goto -51 -> 93
    //   147: astore 7
    //   149: aload 10
    //   151: astore 6
    //   153: aload 9
    //   155: astore 5
    //   157: getstatic 22	com/kenai/jbosh/ServiceLib:LOG	Ljava/util/logging/Logger;
    //   160: getstatic 71	java/util/logging/Level:WARNING	Ljava/util/logging/Level;
    //   163: new 45	java/lang/StringBuilder
    //   166: dup
    //   167: ldc 208
    //   169: invokespecial 50	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   172: aload_3
    //   173: invokevirtual 209	java/net/URL:toString	()Ljava/lang/String;
    //   176: invokevirtual 54	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   179: invokevirtual 57	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   182: aload 7
    //   184: invokevirtual 101	java/util/logging/Logger:log	(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   187: aload 6
    //   189: invokestatic 197	com/kenai/jbosh/ServiceLib:finalClose	(Ljava/io/Closeable;)V
    //   192: aload 5
    //   194: invokestatic 197	com/kenai/jbosh/ServiceLib:finalClose	(Ljava/io/Closeable;)V
    //   197: aload 4
    //   199: invokestatic 197	com/kenai/jbosh/ServiceLib:finalClose	(Ljava/io/Closeable;)V
    //   202: aload_1
    //   203: areturn
    //   204: astore 8
    //   206: aload 6
    //   208: invokestatic 197	com/kenai/jbosh/ServiceLib:finalClose	(Ljava/io/Closeable;)V
    //   211: aload 5
    //   213: invokestatic 197	com/kenai/jbosh/ServiceLib:finalClose	(Ljava/io/Closeable;)V
    //   216: aload 4
    //   218: invokestatic 197	com/kenai/jbosh/ServiceLib:finalClose	(Ljava/io/Closeable;)V
    //   221: aload 8
    //   223: athrow
    //   224: astore 8
    //   226: aload 9
    //   228: astore 5
    //   230: aconst_null
    //   231: astore 6
    //   233: goto -27 -> 206
    //   236: astore 8
    //   238: aload 10
    //   240: astore 6
    //   242: aload 9
    //   244: astore 5
    //   246: goto -40 -> 206
    //   249: astore 7
    //   251: aconst_null
    //   252: astore 6
    //   254: aconst_null
    //   255: astore 5
    //   257: goto -100 -> 157
    //   260: astore 7
    //   262: aload 9
    //   264: astore 5
    //   266: aconst_null
    //   267: astore 6
    //   269: goto -112 -> 157
    //
    // Exception table:
    //   from	to	target	type
    //   93	100	147	java/io/IOException
    //   122	144	147	java/io/IOException
    //   65	82	204	finally
    //   157	187	204	finally
    //   82	93	224	finally
    //   93	100	236	finally
    //   122	144	236	finally
    //   65	82	249	java/io/IOException
    //   82	93	260	java/io/IOException
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.kenai.jbosh.ServiceLib
 * JD-Core Version:    0.6.2
 */